<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增课程目录')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-folder-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">父级目录：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input id="treeId" name="parentId" type="hidden" th:value="${teachingCourseFolder?.folderId}"/>
                    <input class="form-control" type="text" onclick="selectFolderTree()" id="treeName" readonly="true"
                           th:value="${teachingCourseFolder?.folderName}">
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group" style="display: none">
            <label class="col-sm-3 control-label">课程ID：</label>
            <div class="col-sm-8">
                <input name="courseId" class="form-control" type="text" th:value="${course.courseId}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">目录名称：</label>
            <div class="col-sm-8">
                <input name="folderName" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">显示顺序：</label>
            <div class="col-sm-8">
                <input name="orderNum" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "teaching/folder"
    var courseId = [[${course.courseId}]];
    $("#form-folder-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-folder-add').serialize());
        }
    }

    /*课程目录-新增-选择父课程目录树*/
    function selectFolderTree() {
        var options = {
            title: '课程目录选择',
            width: "380",
            url: prefix + "/selectFolderTree/" + $("#treeId").val() + "?courseId=" + courseId,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }
</script>
</body>
</html>
